

all_package_file=/opengauss/openGauss-3.1.0-CentOS-64bit-all.tar.gz
install_root_path=/opengauss/cluster

app_path=${install_root_path}/app/
log_path=${install_root_path}/log/
cm_config_path=${install_root_path}/cm
cm_agent_path=${cm_config_path}/cm_agent
cm_server_path=${cm_config_path}/cm_server

cm_agent_log=${log_path}/cm/cm_agent
cm_server_log=${log_path}/cm/cm_server
monitor_log=${log_path}/cm/om_monitor

datanode_dir=${install_root_path}/datanode/dn1

mkdir -p ${install_root_path}
mkdir ${app_path}
mkdir ${log_path}
mkdir -p ${cm_agent_path}
mkdir -p ${cm_server_path}
mkdir -p ${cm_agent_log}
mkdir -p ${cm_server_log}
mkdir -p ${install_root_path}/tmp
mkdir -p ${monitor_log}

cd ${install_root_path}
mkdir ${install_root_path}/package
tar -zxf ${all_package_file} -C ${install_root_path}/package/
cd ${install_root_path}/package
tar -xf openGauss-3.1.0-CentOS-64bit.tar.bz2 -C ${app_path}
tar -xf openGauss-3.1.0-CentOS-64bit-cm.tar.gz -C ${app_path}

mkdir -p /opengauss/cluster/tool
export GPHOME=/opengauss/cluster/tool
export PATH=$GPHOME/script/gspylib/pssh/bin:$GPHOME/script:$PATH
tar -xf openGauss-3.1.0-CentOS-64bit-om.tar.gz -C ${GPHOME}

export PGHOST=/opengauss/cluster/tmp
mkdir -p ${PGHOST}

export GAUSSHOME=${app_path}
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export PATH=${GAUSSHOME}/bin:${PATH}
export GAUSSLOG=${log_path}

echo "GAUSSHOME: ${GAUSSHOME}"

gs_initdb -D ${datanode_dir} --nodename=nodename -w test@123




touch ${GAUSSHOME}/bin/cluster_manual_start
cp ${GAUSSHOME}/share/config/cm_server.conf.sample ${cm_server_path}/cm_server.conf
cp ${GAUSSHOME}/share/config/cm_agent.conf.sample ${cm_agent_path}/cm_agent.conf
mkdir $GAUSSHOME/share/sslcert/cm

#nohup $GAUSSHOME/bin/om_monitor -L $GAUSSLOG/cm/om_monitor &